package com.huike.web.controller.report;


import com.huike.report.domain.vo.IndexTodoInfoVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.huike.common.core.domain.AjaxResult;
import com.huike.report.service.IReportService;

import java.text.SimpleDateFormat;
import java.util.Date;

@RestController
@RequestMapping("/index")
public class IndexController {

    @Autowired
    private IReportService reportService;


    /**
     * 首页--基础数据统计
     * @param beginCreateTime
     * @param endCreateTime
     * @return
     */
    @GetMapping("/getBaseInfo")
    public AjaxResult getBaseInfo(@RequestParam("beginCreateTime") String beginCreateTime,
                                  @RequestParam("endCreateTime") String endCreateTime){
        return AjaxResult.success(reportService.getBaseInfo(beginCreateTime,endCreateTime));
    }

    /**
     * 首页--今日数据简报
     * @return 查询到的数据
     */
    @GetMapping("/getTodayInfo")
    public AjaxResult getTodayInfo(){
        //return AjaxResult.success("操作成功!",reportService.getTodayInfo(new SimpleDateFormat("yyyy-MM-dd").format(new Date())));
        return AjaxResult.success("操作成功!",reportService.getTodayInfo("2022-04-19"));
    }

    /**
     * 首页--待办数据
     * @param beginCreateTime 开始时间
     * @param endCreateTime   结束时间
     * @return 返回前端数据
     */
    @GetMapping("/getTodoInfo")
    public AjaxResult getTodoInfo( String beginCreateTime, String endCreateTime){
        IndexTodoInfoVO infoVO = reportService.getTodoInfo(beginCreateTime,endCreateTime);
        return AjaxResult.success(infoVO);
    }


}